package com.example.gpsController;

import com.example.pojo.ResponseVo;
import com.example.pojo.SbMessageVo;
import com.example.service.SbMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/sbxx")
@CrossOrigin
public class SbMeesageController {

    @Autowired
    private SbMessageService sbMessageService;

    @GetMapping("/UserSbMeesage")
    public ResponseVo UserSbMeesage() {
        return sbMessageService.UserSbMeesage();
    }

    @GetMapping("/devicLocation/{sbid}")
    public ResponseVo devicLocation(@PathVariable String sbid) {
        return sbMessageService.devicLocation(sbid);
    }

    @GetMapping("/deviceTrackPlayBack/{sbid}/{startTime}/{endTime}")
    public ResponseVo deviceTrackPlayBack(@PathVariable String sbid, @PathVariable String startTime, @PathVariable String endTime) {
        return sbMessageService.deviceTrackPlayBack(sbid, startTime, endTime);
    }

    @PostMapping("/insertMessage")
    public ResponseVo insertMessage(@RequestBody SbMessageVo message) {
        return sbMessageService.insert(message); // 使用 BaseMapper 的 insert 方法
    }

    @PostMapping("/updateMessage")
    public ResponseVo updateMessage(@RequestBody SbMessageVo message) {
        return sbMessageService.updateById(message); // 使用 BaseMapper 的 updateById 方法
    }

    @DeleteMapping("/deleteById/{id}")
    public ResponseVo deleteMessageById(@PathVariable Long id) {
        return sbMessageService.deleteById(id); // 使用 BaseMapper 的 deleteById 方法
    }

    @GetMapping("/MileageStatistics/{sbid}")
    public ResponseVo MileageStatistics(@PathVariable String sbid) {
      return   sbMessageService.MileageStatistics(sbid);
    }
    @GetMapping("/ElectronicFenceInformation/{sbid}")
    public ResponseVo ElectronicFenceInformation(@PathVariable String sbid) {
        return   sbMessageService.ElectronicFenceInformation(sbid);
    }

    @PostMapping("/SaveElectronicFenceInformation")
    public ResponseVo SaveElectronicFenceInformation(@RequestBody Map<String,String> map) {
        return   sbMessageService.SaveElectronicFenceInformation(map);
    }


    @GetMapping("/openState/{sbid}")
    public ResponseVo openState(@PathVariable String sbid) {
        return sbMessageService.openState(sbid);
    }



    @GetMapping("/openElectronicFenceInformation/{sbid}")
    public ResponseVo openElectronicFenceInformation(@PathVariable String sbid) {
        return   sbMessageService.openElectronicFenceInformation(sbid);
    }


    @GetMapping("/closeElectronicFenceInformation/{sbid}")
    public ResponseVo closeElectronicFenceInformation(@PathVariable String sbid) {
        return   sbMessageService.closeElectronicFenceInformation(sbid);
    }
}
